const CompressionPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = /\.(js|css)(\?.*)?$/i
const { defineConfig } = require('@vue/cli-service')
const isProdOrTest = process.env.NODE_ENV !== 'development'

module.exports = defineConfig({
  transpileDependencies: true,
  publicPath: '/',
  lintOnSave: false,
  chainWebpack: config => {
    // config
    //     .plugin('webpack-bundle-analyzer')
    //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)

        if (isProdOrTest) {
          // 对超过10kb的文件gzip压缩
          // config.plugin('compressionPlugin').use(
          //   new CompressionPlugin({
          //     test: productionGzipExtensions, // 需要压缩的文件正则
          //     threshold: 1024*1000, // 文件大小大于这个值时启用压缩
          //     deleteOriginalAssets: true // 压缩后保留原文件
          //   })
          // )
}
}
})
